#ifndef _jumper_h__
#define _jumper_h__
#pragma once
#include "../xlib/xlib.h"
using namespace Sky;

class JumpMan : public myControl
{
public:
	Void init(myResMgr* mgr,PointF pos = PointF(0,0),Vector2F speed = Vector2F(0,0),Vector2F direction = Vector2F(0,0));

	Void adjust(PointF target,Float speed)
	{
		Float d = Helper::distance(_pos,target)/speed;
		_speed.x = (target.x - _pos.x)/d;
		_speed.y = (target.y - _pos.y)/d;
		_target = target;
	}

	Void updateTime(TimeCounter* tc);

	Void Draw(Painter* painter,Rect* parentRect = vNull);

	SetGetProperty(PositionF,PointF,_pos);

	SetGetProperty(Speed,Vector2F,_speed);

	SetGetProperty(Target,PointF,_target);
};

class JumperWin : public myWinlet
{
public:


	JumperWin(){}

	~JumperWin();

	Bool init(myResMgr* mgr,i32 x,i32 y,i32 w,i32 h);

	MsgStatus onPaint(myMsgMgr* mgr,Msg* msg);

	MsgStatus onInput(myMsgMgr* mgr,Msg* msg);

	Void updateTime(TimeCounter* tc);


private:
	JumpMan _man;
};

class Trigger : public myControl
{
public:
	Trigger(PointF pos,Float radis,Trigger* next,Float speed);

	Void Draw(Painter* painter,Rect* parentRect /* = vNull */);

	Bool adjust(JumpMan* man);

	
	SetGetProperty(Radis,Float,_radis);

	SetGetProperty(NextTrigger,Trigger*,_trigger);

	SetGetProperty(Speed,Float,_speed);

	SetGetProperty(PositionF, PointF, _pos);

};

class JumperApp : public myApplet
{
public:

	MsgStatus OnTimer(myMsgMgr* mgr,Msg* msg);

	Bool init(int x,int y,int w,int h);

private:
	JumperWin _win;
};
#endif